import { TokenRequestData, TableResponseData } from '@/types/interface'
import { MaintenanceStatus, BoxLockStatus, DoorStatus, BoxStatus, OnlineStatus } from '@/types/enum'
export interface queryBoxRequestData extends TokenRequestData {
  boxCode: string
  batteryLevel: string
}
interface storeType {
  storeId: string
  merchantId: string
  storeName: string
  address: string
  contactPhone: string
  contactPerson: string
  imageUrls: string
  serviceTime: string
  longtitude: string
  latitude: string
  status: string
  createdTime: string
  updatedTime: string
  image: string | null
}
export interface doorDataType {
  doorNumber: string | null //仓门编号
  maintenanceStatus: MaintenanceStatus //仓门维护状态，0可用/1维护
  doorStatus: DoorStatus | null //仓门状态，0关/1开
  doorStatusTime: string | null //仓门开关时间戳
  inputVoltage: string | null //输入电压
  batteryId: string | null //电池id，放入则赋值，取出则为空，电池无编号则为1
  batteryPowerLevel: string | null //放入的电池电量
  batteryPowerLevelNew: string | null //供电仓门电量(1号仓门)
  batteryTime: string | null
  statusChanging: string | null //状态改变，1正在操作中
  statusChangingTime: string | null //状态改变时间戳
  statusChangingContext: string | null //状态改变上下文
  tempMaintenanceStatus: string | null //临时维护状态
  empty: boolean //换电仓是否为空
  faultStatus: string //仓门故障状态，0无故障/1有故障
}
export interface queryBoxTableCol {
  boxId: number
  boxCode: string
  boxLockId: string
  cameraId: string | null
  boxName: string | null
  longtitude: string
  latitude: string
  imageUrl: string
  doorCount: string
  address: string
  serviceTime: string
  storeId: string
  store: storeType | null
  createdTime: string
  updatedTime: string
  remark: string
  status: string
  boxOnlineStatus: BoxStatus | null
  boxOnlineStatusTime: string | null
  timestamp: string
  battery48VCount: string | null
  battery60VCount: string | null
  doorDataList: doorDataType[] | null
  boxLockStatus: BoxLockStatus
  storeName: string
  storeAddress: string
  contactPhone: string
  contactPerson: string
  validDoor: number[]
}

export type queryBoxResponseData = TableResponseData<queryBoxTableCol>

export type queryBoxResponse = ApiResponseData<queryBoxResponseData>

/** 开启仓门 */
export interface openDoorRequestData extends TokenRequestData {
  boxId: number
  doorId: string
  reason?: string
}
export type openDoorResponse = ApiResponseData<string>

/** 电柜信息 */
export interface queryBoxDetailRequestData extends TokenRequestData {
  boxId: number
}

export type queryBoxBoxDetailResponseData = queryBoxTableCol

export type queryBoxBoxDetailResponse = ApiResponseData<queryBoxBoxDetailResponseData>

/** 操作记录商家 */

export interface queryBoxEmployeeOperationRequestData extends TokenRequestData {
  type: string
  boxId: string
  boxCode: string
  phone: string
}

export interface queryBoxEmployeeOperationTableCol {
  boxId: string
  boxCode: string
  remark: string
  longtitude: number
  latitude: number
  operationUser: string
  createdTime: string
  masterBatteryLevel: string
}
export type queryBoxEmployeeOperationResponseData =
  TableResponseData<queryBoxEmployeeOperationTableCol>

export type queryBoxEmployeeOperationResponse =
  ApiResponseData<queryBoxEmployeeOperationResponseData>

/** 报警记录 */
export interface queryBoxAlarmRequestData extends TokenRequestData {
  boxId: string
}

export interface queryBoxAlarmTableCol {
  boxLoggingId: number
  boxId: number
  userId: string
  orderId: string
  category: string //报警类型
  remark: string //内容
  type: string
  createdTime: string
}
export type queryBoxAlarmResponseData = TableResponseData<queryBoxAlarmTableCol>

export type queryBoxAlarmResponse = ApiResponseData<queryBoxAlarmResponseData>

/** 开仓客服记录 */
export type queryBoxCustomerOperationRequestData = queryBoxAlarmRequestData

export interface queryBoxCustomerOperationTableCol {
  boxCode: string
  customerName: string
  createdTime: string
  remark: string
  batteryStatus: string
}
export type queryBoxCustomerOperationResponseData =
  TableResponseData<queryBoxCustomerOperationTableCol>

export type queryBoxCustomerOperationResponse =
  ApiResponseData<queryBoxCustomerOperationResponseData>

export interface queryBatteryHistoryRequestData {
  userId?: string
  orderId?: string
  boxId?: string
  type?: string
  startTime?: string
  endTime?: string
}

export interface queryBatteryHistoryTableCol {
  boxOperationId: number
  userId: string
  type: string
  boxId: number
  boxCode: string
  boxLockId: string
  doorNumber: string
  doorOpenTime: string
  doorCloseTime: string
  batteryId: string
  batteryPowerLevel: string
  inputVoltage: string
  batteryFeedback: string
  operationData: string
  orderId: string
  boxAddress: string
  createdTime: string
}
export type queryBatteryHistoryResponseData = TableResponseData<queryBatteryHistoryTableCol>
export type queryBatteryHistoryResponse = ApiResponseData<queryBatteryHistoryResponseData>

/**
 * 查询电柜地图
 * @param onlineStatus 网络状态
 * @param type - 查询类型 0 - 全部电柜 1 - 含48V电池 2 - 含60V电池 3 - 1号仓 4 - 维修仓 5 - 沉淀仓
 * @param minPowerLevel - 主控仓最小电量
 * @param maxPowerLevel - 主控仓最大电量
 * @param datedTime - 沉淀时间
 */
export interface queryBoxLocationsRequestData extends TokenRequestData {
  minPowerLevel: number
  maxPowerLevel: number
  onlineStatus: OnlineStatus
  datedTime: string
  type: '0' | '1' | '2' | '3' | '4' | '5'
  storeId: string
}

export interface queryBoxLocationsResponseData {
  boxId: string //电柜ID
  address: string //电柜地址
  longtitude: number //经度
  latitude: number //纬度
  battery48VCanUseCount: number //48V可用数
  battery48VInvalidCount: number //48V不可用数
  battery60VCanUseCount: number //60V可用数
  battery60VInvalidCount: number //60V不可用数
  masterPowerLevel: number //主控仓（1）电量
  datedTime: number //沉淀时间（小时）
}
export type queryBoxLocationsResponse = ApiResponseData<queryBoxLocationsResponseData[]>
